package com.vinjune.bigdata.bloomfilter.tool;

import  com.vinjune.bigdata.bloomfilter.tool.HashProvider.HashFunction;
import  com.vinjune.bigdata.bloomfilter.tool.HashProvider.HashMethod;



/**
 * Created by 000376 on 2018/3/7.
 */
public class HashUtil {
    private HashFunction hashFunction;
    private int size;
    private int hashes;

    public HashUtil(int size, int hashes) {
        this.hashFunction = HashMethod.Murmur3.getHashFunction();
        this.size = size;
        this.hashes = hashes;
    }

    public int[] hash(byte[] bytes) {
        return this.hashFunction.hash(bytes, this.size, this.hashes);
    }

    public static void main(String[] args) {
        HashUtil hash = new HashUtil(100, 3);
        int[] offset = hash.hash("1".getBytes());

        for(int i = 0; i < offset.length; ++i) {
            System.out.println(offset[i]);
        }

    }
}
